Skip to content

feat(vscode-lm): add Copilot modelOptions for agent request classification#11291

Draft
roomote[bot] wants to merge 1 commit intomainfrom
feature/copilot-agent-model-options
Draft

feat(vscode-lm): add Copilot modelOptions for agent request classification#11291
roomote[bot] wants to merge 1 commit intomainfrom
feature/copilot-agent-model-options

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Feb 7, 2026

Related GitHub Issue

Closes: #11289

Description

This PR attempts to address Issue #11289 by enhancing the existing VS Code LM provider to pass modelOptions when the model vendor is GitHub Copilot ("copilot").

What changed:

  • When the VSCode LM handler detects a Copilot model (vendor === "copilot"), it now attaches modelOptions with copilot-integration-id: "roo-code" to every sendRequest call (both createMessage and completePrompt).
  • This uses the modelOptions property on LanguageModelChatRequestOptions (stable since VS Code 1.96). On older VS Code versions, the extra property is silently ignored.
  • Added three helper functions at module scope: isCopilotModel(), buildCopilotModelOptions(), and the COPILOT_VENDOR constant.

Design choices / trade-offs:

  • The copilot-integration-id header value is based on the pattern referenced in the copilot-api project. The exact model options that the Copilot backend uses for billing classification may need further refinement based on feedback from users and the Copilot team.
  • The feature is automatically enabled when the vendor is "copilot" -- no new user-facing settings are required.
  • A type assertion (as vscode.LanguageModelChatRequestOptions) is used because modelOptions was added in @types/vscode 1.96 while the project targets ^1.84.0.

Feedback and guidance are welcome.

Test Procedure

  • Added 4 new unit tests in vscode-lm.spec.ts:
    • should include modelOptions when model vendor is copilot (createMessage)
    • should NOT include modelOptions when model vendor is not copilot (createMessage)
    • should include modelOptions in completePrompt when model vendor is copilot
    • should NOT include modelOptions in completePrompt when model vendor is not copilot
  • All 23 tests pass: cd src && npx vitest run api/providers/__tests__/vscode-lm.spec.ts
  • Full monorepo lint and type-check pass via pre-push hooks.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: No documentation updates are required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A -- no UI changes.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This is a first step toward better Copilot billing integration. The modelOptions values may need to be adjusted based on what the Copilot backend actually expects for proper agent request classification. Community testing with active Copilot subscriptions would be very helpful to validate the billing impact.


Important

Add modelOptions for GitHub Copilot requests in VS Code LM API to aid billing classification.

  • Behavior:
    • Attach modelOptions with copilot-integration-id: "roo-code" to sendRequest calls in createMessage and completePrompt when vendor is "copilot".
    • Uses modelOptions property on LanguageModelChatRequestOptions (requires VS Code >= 1.96).
  • Functions:
    • Add isCopilotModel() to check if model vendor is Copilot.
    • Add buildCopilotModelOptions() to construct model options for Copilot.
  • Tests:
    • Add tests in vscode-lm.spec.ts to verify modelOptions inclusion/exclusion based on vendor.
  • Misc:
    • Add COPILOT_VENDOR constant for vendor string comparison.

This description was created by Ellipsis for cc0c716. You can customize this summary. It will automatically update as commits are pushed.

…ation

When the VS Code LM model vendor is "copilot", attach modelOptions
with copilot-integration-id to sendRequest calls. This allows the
Copilot backend to distinguish agent-initiated requests from
direct user chat, which may help with proper billing classification
of premium vs non-premium requests.

Requires VS Code >= 1.96 where modelOptions became stable; older
versions silently ignore the extra property.

Refs: #11289
@roomote
Copy link
Contributor Author

roomote bot commented Feb 7, 2026

Rooviewer Clock   See task

Clean PR. One minor nit flagged:

  • Remove unnecessary as vscode.LanguageModelChatRequestOptions type assertions (lines 440 and 610 in vscode-lm.ts) -- the resolved @types/vscode already includes modelOptions

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment on lines 436 to +440
const requestOptions: vscode.LanguageModelChatRequestOptions = {
justification: `Roo Code would like to use '${client.name}' from '${client.vendor}', Click 'Allow' to proceed.`,
tools: convertToVsCodeLmTools(metadata?.tools ?? []),
}
...(isCopilotModel(client) ? { modelOptions: buildCopilotModelOptions() } : {}),
} as vscode.LanguageModelChatRequestOptions
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] The as vscode.LanguageModelChatRequestOptions assertion is unnecessary here (and at line 610 in completePrompt). The resolved @types/vscode@1.100.0 already includes modelOptions in LanguageModelChatRequestOptions, so the object literal is assignable without a cast. In createMessage the variable already carries the same type annotation on the left-hand side, making the assertion doubly redundant. Dropping the as casts lets TypeScript catch property-name typos in the object literal.

Suggested change
const requestOptions: vscode.LanguageModelChatRequestOptions = {
justification: `Roo Code would like to use '${client.name}' from '${client.vendor}', Click 'Allow' to proceed.`,
tools: convertToVsCodeLmTools(metadata?.tools ?? []),
}
...(isCopilotModel(client) ? { modelOptions: buildCopilotModelOptions() } : {}),
} as vscode.LanguageModelChatRequestOptions
const requestOptions: vscode.LanguageModelChatRequestOptions = {
justification: `Roo Code would like to use '${client.name}' from '${client.vendor}', Click 'Allow' to proceed.`,
tools: convertToVsCodeLmTools(metadata?.tools ?? []),
...(isCopilotModel(client) ? { modelOptions: buildCopilotModelOptions() } : {}),
}

Fix it with Roo Code or mention @roomote and request a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Support CoPilot provider natively to optimize credit usage

1 participant